package com.pzhu.user.rpc.client;

import com.pzhu.auth.api.AuthApi.PasswordRp;
import com.pzhu.auth.api.AuthApi.PasswordRq;
import com.pzhu.auth.api.PasswordServiceGrpc.PasswordServiceBlockingStub;
import lombok.RequiredArgsConstructor;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class AuthClientService {

    @GrpcClient("auth")
    private PasswordServiceBlockingStub passwordServiceBlockingStub;

    public String generatePasswords(String rePassword) {
        PasswordRq passwordRq = PasswordRq.newBuilder().setPassword(rePassword).build();
        PasswordRp passwordRp = passwordServiceBlockingStub.generatePasswords(passwordRq);
        return passwordRp.getPassword();
    }
}
